#ifndef __THREAD_POOL__
#define __THREAD_POOL__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <signal.h>
#include <pthread.h>
#include <tgmath.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/epoll.h>
#include <mysql/mysql.h>
#include "task_queue.h"
#include "tid_arr.h"
#include "conf.h"
#include "handle_command.h"
#include "getspasswd.h"
#include "pathstack.h"
#include "dir_commands.h"
#include "logon.h"
#define RESP_PWD_RESULT 103
#define CPP68_PATH "./netdisk"
// 检查命令行参数数量是否符合预期
#define ARGS_CHECK(argc, expected) \
    do { \
        if ((argc) != (expected)) { \
            fprintf(stderr, "args num error!\n"); \
            exit(1); \
        } \
    } while (0)

// 检查返回值是否是错误标记,若是则打印msg和错误信息
#define ERROR_CHECK(ret, error_flag, msg) \
    do { \
        if ((ret) == (error_flag)) { \
            perror(msg); \
            exit(1); \
        } \
    } while (0)
#define ERROR_THREAD(ret,success_flag)\
    do { \
        if ((ret) != (success_flag)) { \
            fprintf(stderr,"pthread_create:%s\n",strerror(ret)); \
            exit(1); \
        } \
     } while (0)
typedef struct thread_pool_s{
    tid_arr_t tid_arr;
    task_queue_t task_queue;
    pthread_mutex_t mutex;
    pthread_cond_t cond;
}thread_pool_t; 
int thread_pool_init(int work_num,thread_pool_t*pthread_pool);
int make_worker(thread_pool_t*pthread_pool);
int tcp_init(const char*ip,const char*port);
int epoll_add(int epfd,int fd);
int epoll_del(int epfd,int fd);
#endif
